<template>
  <el-dialog :title=" !form.id  ? '新增 ' : '修改' "
             :close-on-click-modal="false"
             :visible.sync="visible">
    <el-form ref="form"
             :model="form"
             label-width="80px">
      <el-form-item label="id">
        <el-input v-model="form.id"></el-input>
      </el-form-item>
      <el-form-item label="任务编码">
        <el-input v-model="form.taskcode"></el-input>
      </el-form-item>
      <el-form-item label="任务定义名称">
        <el-input v-model="form.taskname"></el-input>
      </el-form-item>
      <el-form-item label="任务Url">
        <el-input v-model="form.url"></el-input>
      </el-form-item>
      <el-form-item label="请求方式">
        <el-select v-model="form.method"
                   placeholder="请选择请求方式">
          <el-option label="POST"
                     value="post"></el-option>
          <el-option label="GET"
                     value="get"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="Corn表达式">
        <el-select v-model="form.corn"
                   placeholder="Corn表达式">
        </el-select>
        <!-- <el-form-item label="自定义">
          <el-input v-model="form.corn"></el-input>
        </el-form-item> -->
      </el-form-item>
    </el-form>
    <div slot="footer"
         class="dialog-footer">
      <el-button @click="cancleForm()">取 消</el-button>
      <el-button type="primary"
                 @click="submitForm()">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import { add } from '@/api/back/task'

export default {
  name: 'baseform',
  data: function () {
    return {
      visible: false,
      form: {
        id: '',
        taskcode: '',
        taskname: '',
        url: '',
        corn: '',
        method: ''
      }
    }
  },
  methods: {
    // 编辑和弹出的初始化页面
    init (id) {
      this.form.id = id || ''
      // 显示弹出层
      this.visible = true
      // 编辑的时候回显
      this.$nextTick(() => {

      })
    },
    cancleForm () {
      this.visible = false
    },
    // 表单提交
    submitForm () {
      var param = {
        id: this.form.id,
        taskcode: this.form.taskcode,
        taskname: this.form.taskcode,
        url: this.form.url,
        corn: this.form.corn,
        method: this.form.method

      }
      add('/taskdefine/add', param, 'post', 'taskcenter', true).then(res => {
      })
    }
  }
}
</script>
